package com.bw.merchant.page.fragment

import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.ToastUtils
import com.bw.base.path.RouterPath
import com.bw.common.view.BaseMvvmFragment
import com.bw.merchant.R
import com.bw.merchant.adapter.ApproveAdapter
import com.bw.merchant.databinding.FragmentTobeconfirmedBinding
import com.bw.merchant.entity.RecordingEntityItem
import com.bw.merchant.vm.MerchantViewModel
import dagger.hilt.android.AndroidEntryPoint

/**
 * 待确认
 */
@AndroidEntryPoint
class TobeConfirmedFragment : BaseMvvmFragment<FragmentTobeconfirmedBinding>() {
    override fun getLayoutId(): Int = R.layout.fragment_tobeconfirmed
    private val mAdapter = ApproveAdapter()
    private val viewModel : MerchantViewModel by activityViewModels()

    override fun initView() {
        mDataBinding.tobeRv.adapter = mAdapter
        viewModel.getRecordingData()

        viewModel.mRecordingSuccess.observe(viewLifecycleOwner){
            mAdapter.data.addAll(it.filter { it.status == "新建" })
            mAdapter.notifyDataSetChanged()
        }

        mAdapter.setOnItemClickListener { adapter, view, position ->
            ARouter.getInstance().build(RouterPath.PATH_APPROVAL_DETAIL_PATH)
                .withInt("iid",mAdapter.data[position].id)
                .navigation()
        }

    }

}